-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
podman: new option --preserve-fd #20866
podman: new option --preserve-fd #20866
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also please split out the logic into a separate function so you can share the conmon setup code between create and exec so we do not have the same logic twice.
libpod/oci_conmon_common.go
Outdated
preserveFDs := ctr.config.PreserveFDs | ||
preserveFDsMap := make(map[uint]interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use struct{} over interface{} as it doesn't need to store any info.
But maybe do we even have to use a map here at all?
Given you already iterate anyway I think this would be simpler:
files := make([]*os.File, len(ctr.config.PreserveFDsList))
for _, i := range ctr.config.PreserveFDsList {
if i > preserveFDs {
preserveFDs = i
}
f = os.NewFile()
files[i] = f
}
cmd.ExtraFiles = files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind this wouldn't work as we do not know the max size without looping over all elements so I the map version is fine with me.
WDYT about renaming it to just |
I like --preserve-fd, and then we just explain the difference, Few users will ever do this, so it becomes easily descoverable and the options in the man page will be right next to each other. |
79f2812
to
f504169
Compare
renamed |
f504169
to
c772e9d
Compare
ready for review |
0ea0ff1
to
f4b7317
Compare
f4b7317
to
db35725
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And don't forget @Luap99's comment
add a new option --preserve-fd that allows to specify a list of FDs to pass down to the container. It is similar to --preserve-fds but it allows to specify a list of FDs instead of the maximum FD number to preserve. --preserve-fd and --preserve-fds are mutually exclusive. It requires crun since runc would complain if any fd below --preserve-fds is not preserved. Closes: containers#20844 Signed-off-by: Giuseppe Scrivano <[email protected]>
db35725
to
01d397a
Compare
can I get another review? |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago, giuseppe, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm I'm sorry for missing your changes yesterday. |
/unhold |
add a new option --preserve-fd that allows to specify a list of FDs to pass down to the container.
It is similar to --preserve-fds but it allows to specify a list of FDs instead of the maximum FD number to preserve.
--preserve-fd and --preserve-fds are mutually exclusive.
It requires crun since runc would complain if any fd below --preserve-fds is not preserved.
Closes: #20844
Does this PR introduce a user-facing change?